<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #ball{
            width: 80px;
            height: 80px;
            background-color: red;
            border-radius: 50%;
            position:absolute;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
    <div id="ball"></div>

    <script>
        var x = 0;
        var y = 0;
        var ball = document.querySelector('#ball');
        document.onkeydown=function(ev){
            if(ev.keyCode===37){
                x=x-5
                ball.style.left=x + 'px'
            }else if(ev.keyCode===39){
                x = x + 5
                ball.style.left=x + 'px'
            }else if(ev.keyCode===38){
                ball.style.top=y + 'px'
                y = y-5
            }else if(ev.keyCode===40){
                y = y + 5
                ball.style.top=y + 'px'
            }
        }
    </script>
</body>
</html>